package com.cms.util;

import javax.servlet.http.HttpServletRequest;

public class StringHelper {
	public static boolean isEmpty(String param) {
		if (param == null || param.equals("") || param.equals(" ")
				|| param.equals("null"))
			return true;
		else
			return false;
	}

	public static String isEmpty(String param, String default_value) {
		if (param == null || param.equals("") | param.equals(" ")
				|| param.trim().equals("null"))
			return default_value;
		else
			return param;
	}
	
	public static String isRequestEmptyString(HttpServletRequest req,String param, String default_value){
		
		return isEmpty(req.getParameter(param), default_value);
		
	}
	
	public static int isRequestParamEmptyInt(HttpServletRequest req,String param, int default_value){
		
		String return_val  = req.getParameter(param);
		if(StringHelper.isEmpty(return_val)){
			return default_value;
		}else{
			return Integer.parseInt(return_val);
		}	
	}
}
